package com.neu.servlet.snn;

import com.alibaba.fastjson.JSONObject;
import com.neu.service.snn.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@WebServlet(name = "ShowPayServlet", urlPatterns = {"/ShowPayServlet.do"})
public class ShowPayServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String u_id=request.getParameter("u_id");
        UserService userService = new UserService();
        List<Map<String,Object>> moneyList = userService.findById(u_id);
       HttpSession session = request.getSession();
        System.out.println(moneyList);
      if ( moneyList!=null){
          String json=JSONObject.toJSONString(moneyList);
          PrintWriter out=response.getWriter();
          out.print(json);
          out.close();
      }
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
